package com.example.xzc.cainiaoshangcheng.Activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.example.xzc.cainiaoshangcheng.R;

import jp.wasabeef.glide.transformations.CropCircleTransformation;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;


public class MainActivity extends AppCompatActivity implements View.OnClickListener{
//

    private Button btn_test1;
    private Button btn_test2;
    private Button btn_test3;
    private ImageView iv_main;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initView();
        initData();
        initEvent();

    }

    private void initEvent() {
        btn_test1.setOnClickListener(this);
        btn_test2.setOnClickListener(this);
        btn_test3.setOnClickListener(this);
    }

    /*
    private void initSwipeRefreshLayout() {
        sLayout.setColorSchemeResources(android.R.color.holo_blue_light,
                                        android.R.color.holo_green_light,
                                        android.R.color.holo_green_light,
                                        android.R.color.holo_red_light);

        sLayout.setDistanceToTriggerSync(100);

        sLayout.setSize(SwipeRefreshLayout.LARGE);

        sLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        temp.clear();
                        temp.addAll(datas);
                        datas.clear();
                        for(int i=0; i<10; i++){
                            datas.add("more"+i);
                       }
                        datas.addAll(temp);
                        myAdapter.notifyDataSetChanged();

                        rv.scrollToPosition(0);

                        sLayout.setRefreshing(false);
                    }
                },3000);
            }
        });



    }
*/

    private void initData() {
        String imageUrl = "http://inthecheesefactory.com/uploads/source/nestedfragment/fragments.png";
        Glide.with(this).load(imageUrl).bitmapTransform(new CropCircleTransformation(this)).into(iv_main);
    }

    private void initView() {

        btn_test1 = (Button) findViewById(R.id.test1);
        btn_test2 = (Button) findViewById(R.id.test2);
        btn_test3 = (Button) findViewById(R.id.test3);
        iv_main = (ImageView) findViewById(R.id.iv_main);

    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent();
        switch (v.getId()){
            case R.id.test1:
                intent.setClass(this,Test1Activity.class);
                this.startActivity(intent);
                break;
            case R.id.test2:
                intent.setClass(this,Test2Activity.class);
                this.startActivity(intent);
                break;
            case R.id.test3:
                intent.setClass(this,Test3Activity.class);
                this.startActivity(intent);
                break;
        }
    }
}
